# 示例1：
# def main():
#     data = int(input('输入一个整数:'))
#
#     try:
#         assert data >= 0, "小于0"# 当data小于0时，触发此异常
#     # except AssertionError as e:
#     #     print(str(e))              #放在这有问题  会出现小于0  -1小于80
#
#         if 90 <= data <= 100:
#             print(str(data) + '在90到100之间')
#         elif 80 <= data <= 90:
#             print(str(data) + '在80到90之间')
#         else:
#             print(str(data) + '小于80')
#     except AssertionError as e:
#         print(str(e))
#
# if __name__ == '__main__':
#     main()

#示例二：
def assert1():
    # message={"app_name":"heartbeat_monitor"}
    message={}
    message["app_name"]="heartbeat_monitor"
    try:
        # assert message['app_name'] == "heartbeat_monitor", "app_name 错误"
        assert isinstance(['app_name'],list), "app_name 错误"
        print(message['app_name'])
    except AssertionError as e:
        print(str(e))
         #！！必须把捕获异常放在最后，否则异常以后的命令还会正常执行

assert1()